import { NextApiRequest, NextApiResponse } from "next";
import { updateUser } from "@/services";

// !!! this config is required
// export const config = {
//     api: {
//         bodyParser: false,
//     },
// };

async function changeStatus(req: NextApiRequest, res: NextApiResponse<APIRes>) {
    await updateUser(req, res);
}

export default async function handler(
    req: NextApiRequest,
    res: NextApiResponse<APIRes>
) {
    if (req.method === "POST") {
        changeStatus(req, res);
    } else {
        res.status(405).json({
            success: false,
            data: {},
            message: "Method not allowed",
        });
    }
}
